﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Evoucher.Business.Security;

namespace Evoucher.Business.Models
{
    public partial class Voucher
    {
        public string PlainPin
        {
            get { return Voucher.DecryptPin(this.Pin, this.ImportDate); }
            set { this.Pin = Voucher.EncryptPin(value, this.ImportDate); }
        }

        public static string EncryptPin(string input, DateTime importDate)
        {
            return TDESProvider.Encrypt(input, importDate.ToString(), true);
        }

        public static string DecryptPin(string input, DateTime importDate)
        {
            return TDESProvider.Decrypt(input, importDate.ToString(), true);
        }

    }

}
